<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Experimental/Independent Film Community</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="description" content="An Independent Film Community" />
<meta name="copyright" content="Cmpe451-ProjectGroup#8" />
<link href="./jsp/user/style/expind-std.css" rel="stylesheet"
	type="text/css" />
<link href="./jsp/user/style/expind.css" rel="stylesheet"
	type="text/css" />
<script language="javascript"
	src="./jsp/user/scripts/jquery-1.8.2.min.js"></script>
<script language="javascript" src="./jsp/user/scripts/expind.js"></script>
</head>
<body>
	<div class="container_24">
		<jsp:include page="header.jsp" />

		<div>
			<input type="hidden" id="movie-id" value="${movie.mid }" />
			<c:if
				test="${requestScope.user.uid eq sessionScope.user.uid && movie.user.uid== sessionScope.user.uid }">
				<select id="project-options">
					<option value="1">Display Project</option>
					<option value="2">Edit Project</option>
				</select>
				<div class="grid_24 hr-line2"></div>
			</c:if>
			<table width="750px">
				<tr>
					<td>
						<table>
							<tr>
								<td style="padding: 5px"><input type="hidden" name="unique"
									value="${requestScope.movie.mid}" /> <img
									src=<c:out value="${ requestScope.movie.poster}"/>
									title=<c:out value="${ requestScope.movie.name }"/>
									width="180px" /> <input type="hidden" name="currurl" /> <input
									type="hidden" name="type" value="user" /></td>
								<td>
									<table>
										<tr>
											<td colspan="2">
												<div class="title-style">
													<c:out value="${ requestScope.movie.name }"></c:out>
													<div class="user-title">${requestScope.movie.genre}</div>
												</div> by ${ requestScope.movie.user.name }
											</td>
										</tr>
										<tr>
											<td colspan="2" style="vertical-align: top; width: 300">
												<div class="info-style">
													<c:out value="${requestScope.movie.summary}" />
													<div class="grid_15 hr-line2"></div>
													<div class="clear height10"></div>

												</div>
											</td>
										</tr>
									</table>
								</td>
							</tr>
						</table>
					</td>
				</tr>

				<tr>
					<td>
						<table class="jobpost">
							<c:if test="${fn:length(requestScope.actorjobs) gt 0}">
								<tr>
									<td colspan="10"><span>Actor Jobs</span></td>
								</tr>
								<tr class="head">
									<td>Age</td>
									<td>Gender</td>
									<td>Height</td>
									<td>Weight</td>
									<td>Hair Color</td>
									<td>Eye Color</td>
									<td>Skin Color</td>
									<td>Description</td>
									<c:if test="${movie.user.uid eq sessionScope.user.uid }">
										<td>Count</td>
									</c:if>
									<td></td>
								</tr>
							</c:if>
							<c:forEach var="actorjob" items="${requestScope.actorjobs}">
								<c:if
									test="${sessionScope.user.uid eq requestScope.movie.user.uid || actorjob.count > 0 }">
									<tr class="jobhead">
										<td><c:if test="${actorjob.fromAge ne -1}">${actorjob.fromAge}</c:if></td>
										<td><c:forEach var="gender" items="${actorjob.genders}">
											${gender.genderName },
										</c:forEach></td>
										<td><c:if test="${actorjob.height ne -1}">${actorjob.height}</c:if></td>
										<td><c:if test="${actorjob.weight ne -1}">${actorjob.weight}</c:if></td>
										<td><c:forEach var="hair" items="${actorjob.hairs}">
											${hair.hairShowName },
										</c:forEach></td>
										<td><c:forEach var="eye" items="${actorjob.eyes}">
											${eye.eyesShowName },
										</c:forEach></td>
										<td><c:forEach var="skin" items="${actorjob.skins}">
											${skin.skinShowName },
										</c:forEach></td>
										<td>${actorjob.description}</td>
										<c:if test="${movie.user.uid eq sessionScope.user.uid }">
											<td>${actorjob.count}</td>
										</c:if>

										<td><c:if
												test="${movie.user.uid ne sessionScope.user.uid}">
												<c:set var="appliedBefore" value="false" scope="request" />
												<c:forEach var="applied" items="${actorjob.applied}">
													<c:if
														test="${applied.key.uid eq sessionScope.user.uid && applied.value ne -1 }">
														<c:set var="appliedBefore" value="true" scope="request" />
													</c:if>
												</c:forEach>
												<c:if test="${not appliedBefore }">
													<a href="apply?toa=${actorjob.ajid}">Apply</a>
												</c:if>
											</c:if></td>

									</tr>
									<c:forEach var="applied" items="${actorjob.applied}">
										<c:if
											test="${movie.user.uid eq sessionScope.user.uid || applied.key.uid eq sessionScope.user.uid }">
											<tr
												class="<c:choose><c:when test="${applied.value eq 1 }">acceptedjob</c:when><c:when test="${applied.value eq -1 }">rejectedjob</c:when><c:otherwise>waitingjob</c:otherwise></c:choose>">
												<td colspan="1"><a href="user?who=${applied.key.uid}">${applied.key.name}</a></td>
												<td colspan="1"><c:if
														test="${applied.value ne 1 && movie.user.uid eq sessionScope.user.uid }">
														<a
															href="apply?action=accept&uid=${applied.key.uid}&ajid=${actorjob.ajid}">Accept</a>
													</c:if></td>
												<td colspan="8"><c:if
														test="${applied.value ne -1 && movie.user.uid eq sessionScope.user.uid }">
														<a
															href="apply?action=reject&uid=${applied.key.uid}&ajid=${actorjob.ajid}">Reject</a>
													</c:if></td>
											</tr>
										</c:if>
									</c:forEach>
								</c:if>
							</c:forEach>
						</table>
					</td>
				</tr>
				<tr>
					<td>
						<table class="jobpost">
							<c:if test="${fn:length(requestScope.crewjobs) gt 0}">
								<tr>
									<td colspan="4"><span>Crew Jobs</span></td>
								</tr>
								<tr class="head">
									<td>Title</td>
									<td>Description</td>
									<c:if test="${movie.user.uid eq sessionScope.user.uid }">
										<td>Count</td>
									</c:if>
									<td></td>
								</tr>
							</c:if>
							<c:forEach var="crewjob" items="${requestScope.crewjobs}">
								<c:if
									test="${sessionScope.user.uid eq requestScope.movie.user.uid || actorjob.count > 0 }">
									<tr class="jobhead">
										<td>${crewjob.title.titleShowName}</td>
										<td>${crewjob.description}</td>
										<c:if test="${movie.user.uid eq sessionScope.user.uid }">
											<td>${crewjob.count}</td>
										</c:if>

										<td><c:if
												test="${movie.user.uid ne sessionScope.user.uid}">
												<c:set var="appliedBefore" value="false" scope="request" />
												<c:forEach var="applied" items="${crewjob.applied}">
													<c:if
														test="${applied.key.uid eq sessionScope.user.uid && applied.value ne -1 }">
														<c:set var="appliedBefore" value="true" scope="request" />
													</c:if>
												</c:forEach>
												<c:if test="${not appliedBefore }">
													<a href="apply?toc=${crewjob.cjid}">Apply</a>
												</c:if>
											</c:if></td>
									</tr>
									<c:forEach var="applied" items="${crewjob.applied}">
										<c:if
											test="${movie.user.uid eq sessionScope.user.uid || applied.key.uid eq sessionScope.user.uid }">
											<tr
												class="<c:choose><c:when test="${applied.value eq 1 }">acceptedjob</c:when><c:when test="${applied.value eq -1 }">rejectedjob</c:when><c:otherwise>waitingjob</c:otherwise></c:choose>">
												<td colspan="1"><a href="user?who=${applied.key.uid}">${applied.key.name}</a></td>
												<td colspan="1"><c:if
														test="${applied.value eq 0 && movie.user.uid eq sessionScope.user.uid }">
														<a
															href="apply?action=accept&uid=${applied.key.uid}&cjid=${crewjob.cjid}">Accept</a>
													</c:if></td>
												<td colspan="8"><c:if
														test="${applied.value eq 0 && movie.user.uid eq sessionScope.user.uid }">
														<a
															href="apply?action=reject&uid=${applied.key.uid}&cjid=${crewjob.cjid}">Reject</a>
													</c:if></td>
											</tr>
										</c:if>
									</c:forEach>
								</c:if>
							</c:forEach>
						</table>
					</td>
				</tr>
			</table>
		</div>
	</div>
	<!-- wrapper BİTİŞ -->
</body>
</html>
